//
//  CSTabbarController.m
//  CZ爱鲜蜂
//
//  Created by chenshuai on 2017/2/18.
//  Copyright © 2017年 陈帅. All rights reserved.
//

#import "AXFTabbarController.h"
#import "AXFNavigationController.h"
@interface AXFTabbarController ()

@end

@implementation AXFTabbarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSMutableArray *mutable = [[NSMutableArray alloc]init];
    [mutable addObject:[self createChildViewControllerWithClassame:@"UIViewController" imageName:@"v2_home" title:@"首页"]];
    [mutable addObject:[self createChildViewControllerWithClassame:@"UIViewController" imageName:@"v2_order" title:@"闪电快送"]];
    [mutable addObject:[self createChildViewControllerWithClassame:@"UIViewController" imageName:@"shopCart" title:@"购物车"]];
    [mutable addObject:[self createChildViewControllerWithClassame:@"UIViewController" imageName:@"v2_my" title:@"我的"]];
    self.viewControllers = mutable;
    
}

-(UINavigationController *)createChildViewControllerWithClassame:(NSString *)clsname imageName:(NSString *)imageName title:(NSString *)title {
    Class cls = NSClassFromString(clsname);
    UIViewController *controller = [[cls alloc]init];
    controller.title = title;
    self.tabBar.tintColor = [UIColor colorWithRed:254/255.0 green:208/255.0 blue:9/255.0 alpha:1];
    controller.tabBarItem.image = [UIImage imageNamed:imageName];
    NSString *selectedImageName = [imageName stringByAppendingString:@"_r"];
    controller.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    AXFNavigationController *nav = [[AXFNavigationController alloc]initWithRootViewController:controller];
    return nav;
}

@end
